package 生产者消费者模型;

import java.util.LinkedList;
import java.util.Queue;

public class Data {
    private static Queue<Integer> queue = new LinkedList<Integer>();

    synchronized public void addData(int data) {
        queue.add(data);
    }

    synchronized public void deleteData() throws Exception {
        if (queue.size() > 0)
            queue.poll();
        else
            throw new Exception("数据为空...");
    }

    public int getDataLen() {
        return queue.size();
    }

}
